#include <stdio.h>
#include <stdbool.h>
struct ListNode
{
	int val;
	struct ListNode* next;
};

struct ListNode* detect(struct ListNode* head)
{
	struct ListNode* fast = head;
	struct ListNode* slow = head;
	while (fast != NULL && fast->next != NULL)
	{
		slow = slow->next;
		fast = fast->next->next;
		if (fast == slow)
			return true;
	}
	return false;
}